import moment, { Moment } from 'moment'
export * from './Storage'
export * from './history'


//处理验证码返回值
export const resolveBase64 = (src: string) => {
  return 'data:image/png;base64,' + src
}


// 时间范围选择器专用, 接受一个2长度moment数组,转为字符串
export const resolveTime = (timeArr: Moment[], formartString: string = 'YYYY-MM-DD') => {
  if (!timeArr) {
    console.warn('timeArr参数不能为空')
    return {}
  }
  let beginCreateTime = moment(timeArr[0]).format(formartString)
  let endCreateTime = moment(timeArr[1]).format(formartString)

  return { beginCreateTime, endCreateTime }
}


// 手机号中间四位加密(135****6555)
export const resolveMobile = (mobileNumber: string) => {
  return mobileNumber?.replace(
    /^(\d{3})\d{4}(\d{4})$/,
    (match: string, p1: string, p2: string) => `${p1}****${p2}`
  )
}

/* 企业级手机号正则 */
export const mobileReg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/


